#!/usr/bin/env ruby

puts "run kk-irc-bot and proxy in screen "

#sudo -u kk -i bash -c "cd /home/kk/dev/kk-irc-bot ; screen -dm tmux -c \" ./irc.rb ub.conf \" "
#sudo -ukk -i bash -c "cd /home/kk/dev/kk-irc-bot;screen -d -m ./irc.rb avplayer.conf &"


def tt
  Thread.new {yield}
end
p ENV['PATH']
s = `ps -e f | grep -E 'ub.con[f]' -i `
p s
if s.size ==0 
  p ' run ub.conf '
  #p `bundle update `
  #`rm Gemfile.lock`
  tt {`screen -S ircUb -dm sh -c "PATH=\"/home/kk/ruby/bin:$PATH\" && cd /home/kk/dev/kk-irc-bot/ && ruby irc.rb ub.conf ; sleep 100 " ` }
end
#p ' run goagent '
#tt { `screen -dm python2 /home/kk/dev/goagent/local/proxy.py `}

sleep 0.1 while Thread.list.size > 1
